import { inferAsyncReturnType } from '@trpc/server';
import { CreateHTTPContextOptions } from '@trpc/server/adapters/standalone';


export interface IContext {
    user: string | undefined;
}

export async function createContext({ req, res, }: CreateHTTPContextOptions): Promise<IContext> {
    async function getUserFromHeader() {
        if (req.headers.authorization)
        {
            return req.headers.authorization
        }
    }
    const user = await getUserFromHeader();

    return {
        user,
    };
}

export type Context = inferAsyncReturnType<typeof createContext>;
